#include "SMESHGUI_SingleEditDlg.h"
#include "SMESHGUI_MultiEditDlg.h"
#include "SMESHGUI_GroupOpDlg.h"
+#include "SMESHGUI_GroupOnShapeDlg.h"
#include "SMESHGUI_DeleteGroupDlg.h"
#include "SMESHGUI_SmoothingDlg.h"
#include "SMESHGUI_RenumberingDlg.h"
#include "SMESHGUI_MakeNodeAtPointDlg.h"
#include "SMESHGUI_BuildCompoundDlg.h"
#include "SMESHGUI_ComputeDlg.h"
+#include "SMESHGUI_FileInfoDlg.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_MeshUtils.h"
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
-#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
+#include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
// Qt includes
// #define INCLUDE_MENUITEM_DEF // VSR commented ????????
// VTK includes
#include <vtkScalarBarActor.h>
+#include <vtkCamera.h>
+#include <vtkRenderer.h>
+#include <vtkPlane.h>
// SALOME KERNEL includes
#include <SALOMEDS_Study.hxx>
#include <SALOMEDSClient_StudyBuilder.hxx>
#include <SALOMEDSClient_SComponent.hxx>
+#include <SALOMEDSClient_ClientFactory.hxx>
+#include <SALOMEDSClient_IParameters.hxx>
// OCCT includes
#include <Standard_ErrorHandler.hxx>
+#include <NCollection_DataMap.hxx>
//namespace{
// Declarations
// Definitions
//=============================================================
- void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
- int theCommandID)
+ void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
+ int theCommandID )
{
QStringList filter;
- string myExtension;
-
- if(theCommandID == 113){
- filter.append(QObject::tr("MED files (*.med)"));
- filter.append(QObject::tr("All files (*)"));
- }else if (theCommandID == 112){
- filter.append(QObject::tr("IDEAS files (*.unv)"));
- }else if (theCommandID == 111){
- filter.append(QObject::tr("DAT files (*.dat)"));
- }
- QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
- "",
- filter,
- QObject::tr("Import mesh"),
- true);
- if(!filename.isEmpty()) {
+ std::string myExtension;
+
+ if ( theCommandID == 113 ) {
+ filter.append( QObject::tr( "MED files (*.med)" ) );
+ filter.append( QObject::tr( "All files (*)" ) );
+ }
+ else if ( theCommandID == 112 ) {
+ filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
+ }
+ else if ( theCommandID == 111 ) {
+ filter.append( QObject::tr( "DAT files (*.dat)" ) );
+ }
+
+ QString anInitialPath = "";
+ if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+ anInitialPath = QDir::currentPath();
+
+ QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
+ anInitialPath,
+ filter,
+ QObject::tr( "SMESH_IMPORT_MESH" ) );
+ if ( filenames.count() > 0 ) {
SUIT_OverrideCursor wc;
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- try {
+ QStringList errors;
+ bool isEmpty = false;
+ for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
+ QString filename = *it;
SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
- switch ( theCommandID ) {
- case 112:
- {
- aMeshes->length( 1 );
- aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.toLatin1().data());
- break;
- }
- case 113:
- {
- SMESH::DriverMED_ReadStatus res;
- aMeshes = theComponentMesh->CreateMeshesFromMED(filename.toLatin1().data(),res);
- if ( res != SMESH::DRS_OK ) {
- wc.suspend();
- SUIT_MessageBox::warning(SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr(QString("SMESH_DRS_%1").arg(res).
- toLatin1().data()));
- aMeshes->length( 0 );
- wc.resume();
+ try {
+ switch ( theCommandID ) {
+ case 111:
+ {
+ // DAT format (currently unsupported)
+ errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
+ arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
+ break;
+ }
+ case 112:
+ {
+ // UNV format
+ aMeshes->length( 1 );
+ aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
+ if ( aMeshes[0]->_is_nil() )
+ errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
+ arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
+ break;
+ }
+ case 113:
+ {
+ // MED format
+ SMESH::DriverMED_ReadStatus res;
+ aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
+ if ( res != SMESH::DRS_OK ) {
+ errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
+ arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
+ }
+ break;
}
- break;
}
}
+ catch ( const SALOME::SALOME_Exception& S_ex ) {
+ errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
+ arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
+ }
- bool isEmpty = false;
for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
_PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
if ( aMeshSO ) {
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
_PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
- aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
+ 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
+ }
+ else {
isEmpty = true;
+ }
}
+ }
- if ( isEmpty ) {
- wc.suspend();
- SUIT_MessageBox::warning(SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_DRS_EMPTY"));
- wc.resume();
- }
+ // update Object browser
+ SMESHGUI::GetSMESHGUI()->updateObjBrowser();
- SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+ // show Error message box if there were errors
+ if ( errors.count() > 0 ) {
+ SUIT_MessageBox::critical( SMESHGUI::desktop(),
+ QObject::tr( "SMESH_ERROR" ),
+ QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
}
- catch (const SALOME::SALOME_Exception& S_ex){
- wc.suspend();
- SalomeApp_Tools::QtCatchCorbaException(S_ex);
- wc.resume();
+
+ // show warning message box, if some imported mesh is empty
+ if ( isEmpty ) {
+ SUIT_MessageBox::warning( SMESHGUI::desktop(),
+ QObject::tr( "SMESH_WRN_WARNING" ),
+ QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
}
}
}
-
void ExportMeshToFile( int theCommandID )
{
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
return;
}
// PAL18696
- QString v21( aMesh->GetVersionString( SMESH::MED_V2_1, 2));
- QString v22( aMesh->GetVersionString( SMESH::MED_V2_2, 2));
+ QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
+ QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
}
if ( resMgr )
toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
- if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
-
- aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
+ QString anInitialPath = "";
+ if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+ anInitialPath = QDir::currentPath();
+ if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
+ if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
+ aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
+ aFilter, aTitle, false);
+ }
else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
QStringList filters;
QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
fd->setWindowTitle( aTitle );
fd->setFilters( filters );
fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
+ if ( !anInitialPath.isEmpty() )
+ fd->setDirectory( anInitialPath );
+ fd->selectFile(anIObject->getName());
bool is_ok = false;
while (!is_ok) {
- fd->exec();
- aFilename = fd->selectedFile();
+ if ( fd->exec() )
+ aFilename = fd->selectedFile();
aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
is_ok = true;
}
delete fd;
}
- else {
+ else { // Export to MED
QStringList filters;
+ QString aDefaultFilter;
QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
- for ( ; it != aFilterMap.end(); ++it )
+ for ( ; it != aFilterMap.end(); ++it ) {
filters.push_back( it.key() );
+ if (it.value() == SMESH::MED_V2_2)
+ aDefaultFilter = it.key();
+ }
//SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
fd->setWindowTitle( aTitle );
fd->setFilters( filters );
- fd->selectFilter( QObject::tr("MED 2.2 (*.med)") );
+ //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
+ fd->selectFilter(aDefaultFilter);
fd->SetChecked(toCreateGroups);
+ if ( !anInitialPath.isEmpty() )
+ fd->setDirectory( anInitialPath );
+ fd->selectFile(anIObject->getName());
bool is_ok = false;
while (!is_ok) {
- fd->exec();
- aFilename = fd->selectedFile();
+ if ( fd->exec() )
+ aFilename = fd->selectedFile();
aFormat = aFilterMap[fd->selectedFilter()];
is_ok = true;
if ( !aFilename.isEmpty()
LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeIOR) anIOR;
+
+ int objectCount = 0;
QString aParentComponent = QString::null;
for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
{
+ _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
+ if (aSO) {
+ // check if object is not reference
+ _PTR(SObject) refobj;
+ if ( !aSO->ReferencedObject( refobj ) )
+ objectCount++;
+ }
+
QString cur = anIt.Value()->getComponentDataType();
if( aParentComponent.isNull() )
aParentComponent = cur;
aParentComponent = "";
}
+ if ( objectCount == 0 )
+ return; // No Valid Objects Selected
+
if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
SUIT_MessageBox::warning( SMESHGUI::desktop(),
QObject::tr("ERR_ERROR"),
(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_REALLY_DELETE"),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
return;
SUIT_ViewManager* vm = anApp->activeViewManager();
int nbSf = vm->getViewsCount();
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
- _PTR(GenericAttribute) anAttr;
- _PTR(AttributeIOR) anIOR;
-
SALOME_ListIteratorOfListIO It(selected);
aStudyBuilder->NewCommand(); // There is a transaction
continue;
}
+ _PTR(SObject) refobj;
+ if ( aSO && aSO->ReferencedObject( refobj ) )
+ continue; // skip references
+
// put the whole hierarchy of sub-objects of the selected SO into a list and
// then treat them all starting from the deepest objects (at list back)
- list< _PTR(SObject) > listSO;
+ std::list< _PTR(SObject) > listSO;
listSO.push_back( aSO );
- list< _PTR(SObject) >::iterator itSO = listSO.begin();
+ std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
for ( ; itSO != listSO.end(); ++itSO ) {
_PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
for (it->InitEx(false); it->More(); it->Next())
// treat SO's in the list starting from the back
- list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
+ std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
for ( ; ritSO != listSO.rend(); ++ritSO ) {
_PTR(SObject) SO = *ritSO;
if ( !SO ) continue;
- string anEntry = SO->GetID();
+ std::string anEntry = SO->GetID();
/** Erase graphical object **/
if(SO->FindAttribute(anAttr, "AttributeIOR")){
break;
}
+ case 150: //MED FILE INFORMATION
+ {
+ SALOME_ListIO selected;
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ if( aSel )
+ aSel->selectedObjects( selected );
+ if( selected.Extent() )
+ {
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+ SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
+ if ( !aMesh->_is_nil() )
+ {
+ SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
+ dlg.exec();
+ }
+ }
+ break;
+ }
+
case 122: // EXPORT MED
case 121:
case 123:
::SetDisplayEntity(theCommandID);
break;
+ case 221: // Orientation of faces
+ {
+ LightApp_SelectionMgr* mgr = selectionMgr();
+ SALOME_ListIO selected; mgr->selectedObjects( selected );
+
+ SALOME_ListIteratorOfListIO it(selected);
+ for( ; it.More(); it.Next()) {
+ Handle(SALOME_InteractiveObject) anIObject = it.Value();
+ if(anIObject->hasEntry()) {
+ if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
+ anActor->SetFacesOriented( !anActor->GetFacesOriented() );
+ }
+ }
+ }
+ break;
+ }
+
case 214: // UPDATE
{
if(checkLock(aStudy)) break;
( new SMESHGUI_BuildCompoundDlg( this ) )->show();
}
break;
+
case 407: // DIAGONAL INVERSION
case 408: // Delete diagonal
{
}*/
break;
}
+ case 806: // CREATE GEO GROUP
+ {
+ startOperation( 806 );
+ break;
+ }
case 801: // CREATE GROUP
{
if ( !vtkwnd )
if( aSel )
aSel->selectedObjects( selected );
+ bool isAny = false; // iss there any appropriate object selected
+
SALOME_ListIteratorOfListIO It( selected );
for ( ; It.More(); It.Next() )
{
{
aName = anAttr;
QString newName = QString(aName->Value().c_str());
- newName = LightApp_NameDlg::getName(desktop(), newName);
- if ( !newName.isEmpty() )
- {
- //old source: aStudy->renameIObject( IObject, newName );
- aName->SetValue( newName.toLatin1().data() );
- // 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.toLatin1().data() );
-
- updateObjBrowser();
+ // check type to prevent renaming of inappropriate objects
+ int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
+ if (aType == MESH || aType == GROUP ||
+ aType == SUBMESH || aType == SUBMESH_COMPOUND ||
+ aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
+ aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
+ aType == HYPOTHESIS || aType == ALGORITHM)
+ {
+ isAny = true;
+ newName = LightApp_NameDlg::getName(desktop(), newName);
+ if ( !newName.isEmpty() )
+ {
+ //old source: aStudy->renameIObject( IObject, newName );
+ aName->SetValue( newName.toLatin1().constData() );
+
+ // 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.toLatin1().constData() );
+
+ updateObjBrowser();
+ }
}
}
}
+ } // for
+
+ if (!isAny) {
+ SUIT_MessageBox::warning(desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
}
break;
}
}
break;
}
+ case 4043: { // CLEAR_MESH
+
+ if(checkLock(aStudy)) break;
+
+ SALOME_ListIO selected;
+ if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
+ aSel->selectedObjects( selected );
+
+ SUIT_OverrideCursor wc;
+ SALOME_ListIteratorOfListIO It (selected);
+ for ( ; It.More(); It.Next() )
+ {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ SMESH::SMESH_Mesh_var aMesh =
+ SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
+ if ( aMesh->_is_nil()) continue;
+ try {
+ SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
+ aMesh->Clear();
+ _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
+ SMESH::ModifiedMesh( aMeshSObj, false, true);
+ // hide groups and submeshes
+ _PTR(ChildIterator) anIter =
+ SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
+ for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
+ {
+ _PTR(SObject) so = anIter->Value();
+ SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
+ }
+ }
+ catch (const SALOME::SALOME_Exception& S_ex){
+ wc.suspend();
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
+ wc.resume();
+ }
+ }
+ SMESH::UpdateView();
+ updateObjBrowser();
+ break;
+ }
case 4051: // RENUMBERING NODES
{
if(checkLock(aStudy)) break;
createSMESHAction( 125, "EXPORT_MED" );
createSMESHAction( 126, "EXPORT_UNV" );
createSMESHAction( 141, "EXPORT_STL" );
+ createSMESHAction( 150, "FILE_INFO" );
createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
createSMESHAction( 5105, "SEL_FILTER_LIB" );
createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
- createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
+ createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
+ createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
createSMESHAction( 804, "ADD" );
createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
+ createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
createSMESHAction( 220, "ALL" );
+ createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
createSMESHAction( 1100, "EDIT_HYPO" );
createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
createSMESHAction( 1102, "UNASSIGN" );
createMenu( 5105, toolsId, -1 );
- createMenu( 702, meshId, -1 );
+ createMenu( 702, meshId, -1 ); // "Mesh" menu
createMenu( 703, meshId, -1 );
createMenu( 704, meshId, -1 );
createMenu( 710, meshId, -1 );
createMenu( 701, meshId, -1 );
createMenu( separator(), meshId, -1 );
createMenu( 801, meshId, -1 );
+ createMenu( 806, meshId, -1 );
createMenu( 802, meshId, -1 );
createMenu( 803, meshId, -1 );
createMenu( separator(), meshId, -1 );
createMenu( 4041, removeId, -1 );
createMenu( 4042, removeId, -1 );
+ createMenu( 4043, removeId, -1 );
createMenu( 4051, renumId, -1 );
createMenu( 4052, renumId, -1 );
createTool( 701, meshTb );
createTool( separator(), meshTb );
createTool( 801, meshTb );
+ createTool( 806, meshTb );
createTool( 802, meshTb );
createTool( 803, meshTb );
createTool( separator(), meshTb );
createTool( separator(), addRemTb );
createTool( 4041, addRemTb );
createTool( 4042, addRemTb );
+ createTool( 4043, addRemTb );
createTool( separator(), addRemTb );
createTool( 4051, addRemTb );
createTool( 4052, addRemTb );
createTool( 214, dispModeTb );
QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
- QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
+ QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
myRules.clear();
QString OB = "'ObjectBrowser'",
// popup for object browser
+ createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
createPopupItem( 803, OB, group ); // EDIT_GROUP
createPopupItem( 903, OB, mesh_group ); // WHAT_IS
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 801, OB, mesh ); // CREATE_GROUP
+ createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
popupMgr()->insert( separator(), -1, 0 );
- createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
+ createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
- createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
+ createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
+ popupMgr()->insert( separator(), -1, 0 );
+ createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
popupMgr()->insert( separator(), -1, 0 );
QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
+
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
popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
+ //-------------------------------------------------
+ // Orientation of faces
+ //-------------------------------------------------
+ popupMgr()->insert( action( 221 ), -1, -1 );
+ popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
+ popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
+
//-------------------------------------------------
// Color / Size
//-------------------------------------------------
this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
}
+//================================================================================
+/*!
+ * \brief Return true if SMESH or GEOM objects are selected.
+ * Is called form LightApp_Module::activateModule() which clear selection if
+ * not isSelectionCompatible()
+ */
+//================================================================================
+
+bool SMESHGUI::isSelectionCompatible()
+{
+ bool isCompatible = true;
+ SALOME_ListIO selected;
+ if ( LightApp_SelectionMgr *Sel = selectionMgr() )
+ Sel->selectedObjects( selected );
+
+ SALOME_ListIteratorOfListIO It( selected );
+ for ( ; isCompatible && It.More(); It.Next())
+ isCompatible =
+ ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
+ ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
+
+ return isCompatible;
+}
+
bool SMESHGUI::activateModule( SUIT_Study* study )
{
bool res = SalomeApp_Module::activateModule( study );
action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
+ action( 33)->setEnabled(true); // Delete: Key_Delete
+ action(1101)->setEnabled(true); // Rename: Key_F2
+
return res;
}
action(112)->setShortcut(QKeySequence()); // Import UNV
action(113)->setShortcut(QKeySequence()); // Import MED
+ action( 33)->setEnabled(false); // Delete: Key_Delete
+ action(1101)->setEnabled(false); // Rename: Key_F2
+
return SalomeApp_Module::deactivateModule( study );
}
return QString( anIOR.in() );
}
-LightApp_Selection* SMESHGUI::createSelection( const QString& client, LightApp_SelectionMgr* mgr ) const
+void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
{
- return new SMESHGUI_Selection( client, mgr );
+ SalomeApp_Module::contextMenuPopup( client, menu, title );
+ SALOME_ListIO lst;
+ selectionMgr()->selectedObjects( lst );
+ if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
+ Handle(SALOME_InteractiveObject) io = lst.First();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
+ _PTR(Study) study = appStudy->studyDS();
+ _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
+ if ( obj ) {
+ QString aName = QString( obj->GetName().c_str() );
+ while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
+ aName.remove( (aName.length() - 1), 1 );
+ title = aName;
+ }
+ }
+}
+
+LightApp_Selection* SMESHGUI::createSelection() const
+{
+ return new SMESHGUI_Selection();
}
void SMESHGUI::windows( QMap<int, int>& aMap ) const
addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
+ setPreferenceProperty( qaGroup, "columns", 2 );
addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
- setPreferenceProperty( precGroup, "columns", 1 );
+ setPreferenceProperty( precGroup, "columns", 2 );
int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
setPreferenceProperty( prec, "max", 16 );
int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
+ setPreferenceProperty( dispgroup, "columns", 2 );
int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
QStringList modes;
modes.append( "Wireframe" );
setPreferenceProperty( dispmode, "indexes", indices );
int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
+ setPreferenceProperty( exportgroup, "columns", 2 );
addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
+ int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
+ setPreferenceProperty( computeGroup, "columns", 2 );
+ int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
+ modes.clear();
+ modes.append( "Never" );
+ modes.append( "Errors only" );
+ modes.append( "Always" );
+ indices.clear();
+ indices.append( 0 );
+ indices.append( 1 );
+ indices.append( 2 );
+ setPreferenceProperty( notifyMode, "strings", modes );
+ setPreferenceProperty( notifyMode, "indexes", indices );
+
int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
+ setPreferenceProperty( nodeGroup, "columns", 2 );
addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
setPreferenceProperty( nodeSz, "max", 5 );
int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
+ setPreferenceProperty( elemGroup, "columns", 2 );
addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
- addPreference( "", elemGroup, LightApp_Preferences::Space );
+ int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
+
+ setPreferenceProperty( sp, "hstretch", 0 );
+ setPreferenceProperty( sp, "vstretch", 0 );
int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
setPreferenceProperty( shrink, "min", 0 );
setPreferenceProperty( shrink, "max", 100 );
+ int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
+ setPreferenceProperty( orientGroup, "columns", 1 );
+
+ addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
+ int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
+
+ setPreferenceProperty( orientScale, "min", 0.05 );
+ setPreferenceProperty( orientScale, "max", 0.5 );
+ setPreferenceProperty( orientScale, "step", 0.05 );
+
+ addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
+
int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
+ setPreferenceProperty( selGroup, "columns", 2 );
addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
setPreferenceProperty( selW, "max", 5 );
int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
+ setPreferenceProperty( preGroup, "columns", 2 );
addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
setPreferenceProperty( preW, "max", 5 );
int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
+ setPreferenceProperty( precSelGroup, "columns", 2 );
addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
+ setPreferenceProperty( fontGr, "columns", 2 );
int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
setPreferenceProperty( lfont, "widget_flags", wflag );
int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
+ setPreferenceProperty( colorsLabelsGr, "columns", 2 );
int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
setPreferenceProperty( numcol, "min", 2 );
setPreferenceProperty( numlab, "max", 65 );
int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
+ setPreferenceProperty( orientGr, "columns", 2 );
int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
QStringList orients;
orients.append( tr( "SMESH_VERTICAL" ) );
setPreferenceProperty( orient, "indexes", indices );
int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
+ setPreferenceProperty( posVSizeGr, "columns", 2 );
int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
setPreferenceProperty( hv, "step", 0.1 );
int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
+ setPreferenceProperty( posHSizeGr, "columns", 2 );
int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
case 704: // Edit mesh/sub-mesh
op = new SMESHGUI_MeshOp( false );
break;
+ case 806: // Create group on geom
+ op = new SMESHGUI_GroupOnShapeOp();
+ break;
case 417: //convert to quadratic
op = new SMESHGUI_ConvToQuadOp();
break;
return aSColor;
}
+
+const char gSeparator = '_'; // character used to separate parameter names
+const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
+
+/*!
+ * \brief Store visual parameters
+ *
+ * This method is called just before the study document is saved.
+ * Store visual parameters in AttributeParameter attribue(s)
+ */
+void SMESHGUI::storeVisualParameters (int savePoint)
+{
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+ if (!appStudy || !appStudy->studyDS())
+ return;
+ _PTR(Study) studyDS = appStudy->studyDS();
+
+ // componentName is used for encoding of entries when storing them in IParameters
+ std::string componentName = myComponentSMESH->ComponentDataType();
+ //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
+ //if (!aSComponent) return;
+
+ // IParameters
+ _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
+ componentName.c_str(),
+ savePoint);
+ _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+
+ // viewers counters are used for storing view_numbers in IParameters
+ int vtkViewers = 0;
+
+ // main cycle to store parameters of displayed objects
+ QList<SUIT_ViewManager*> lst;
+ QList<SUIT_ViewManager*>::Iterator it;
+ getApp()->viewManagers(lst);
+ for (it = lst.begin(); it != lst.end(); it++)
+ {
+ SUIT_ViewManager* vman = *it;
+ QString vType = vman->getType();
+
+ // saving VTK actors properties
+ if (vType == SVTK_Viewer::Type())
+ {
+ QVector<SUIT_ViewWindow*> views = vman->getViews();
+ for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
+ {
+ if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
+ {
+ vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
+ allActors->InitTraversal();
+ while (vtkActor* actor = allActors->GetNextActor())
+ {
+ if (actor->GetVisibility()) // store only visible actors
+ {
+ SMESH_Actor* aSmeshActor = 0;
+ if (actor->IsA("SMESH_Actor"))
+ aSmeshActor = SMESH_Actor::SafeDownCast(actor);
+ if (aSmeshActor && aSmeshActor->hasIO())
+ {
+ Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
+ if (io->hasEntry())
+ {
+ // entry is "encoded" = it does NOT contain component adress,
+ // since it is a subject to change on next component loading
+ std::string entry = ip->encodeEntry(io->getEntry(), componentName);
+
+ std::string param, vtkParam = vType.toLatin1().data();
+ vtkParam += gSeparator;
+ vtkParam += QString::number(vtkViewers).toLatin1().data();
+ vtkParam += gSeparator;
+
+ // Visibility
+ param = vtkParam + "Visibility";
+ ip->setParameter(entry, param, "On");
+
+ // Representation
+ param = vtkParam + "Representation";
+ ip->setParameter(entry, param, QString::number
+ ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
+
+ // IsShrunk
+ param = vtkParam + "IsShrunk";
+ ip->setParameter(entry, param, QString::number
+ ((int)aSmeshActor->IsShrunk()).toLatin1().data());
+
+ // Displayed entities
+ unsigned int aMode = aSmeshActor->GetEntityMode();
+ bool isE = aMode & SMESH_Actor::eEdges;
+ bool isF = aMode & SMESH_Actor::eFaces;
+ bool isV = aMode & SMESH_Actor::eVolumes;
+
+ QString modeStr ("e");
+ modeStr += gDigitsSep; modeStr += QString::number(isE);
+ modeStr += gDigitsSep; modeStr += "f";
+ modeStr += gDigitsSep; modeStr += QString::number(isF);
+ modeStr += gDigitsSep; modeStr += "v";
+ modeStr += gDigitsSep; modeStr += QString::number(isV);
+
+ param = vtkParam + "Entities";
+ ip->setParameter(entry, param, modeStr.toLatin1().data());
+
+ // Colors (surface:edge:)
+ vtkFloatingPointType r, g, b;
+
+ aSmeshActor->GetSufaceColor(r, g, b);
+ QString colorStr ("surface");
+ colorStr += gDigitsSep; colorStr += QString::number(r);
+ colorStr += gDigitsSep; colorStr += QString::number(g);
+ colorStr += gDigitsSep; colorStr += QString::number(b);
+
+ aSmeshActor->GetBackSufaceColor(r, g, b);
+ colorStr += gDigitsSep; colorStr += "backsurface";
+ colorStr += gDigitsSep; colorStr += QString::number(r);
+ colorStr += gDigitsSep; colorStr += QString::number(g);
+ colorStr += gDigitsSep; colorStr += QString::number(b);
+
+ aSmeshActor->GetEdgeColor(r, g, b);
+ colorStr += gDigitsSep; colorStr += "edge";
+ colorStr += gDigitsSep; colorStr += QString::number(r);
+ colorStr += gDigitsSep; colorStr += QString::number(g);
+ colorStr += gDigitsSep; colorStr += QString::number(b);
+
+ aSmeshActor->GetNodeColor(r, g, b);
+ colorStr += gDigitsSep; colorStr += "node";
+ colorStr += gDigitsSep; colorStr += QString::number(r);
+ colorStr += gDigitsSep; colorStr += QString::number(g);
+ colorStr += gDigitsSep; colorStr += QString::number(b);
+
+ param = vtkParam + "Colors";
+ ip->setParameter(entry, param, colorStr.toLatin1().data());
+
+ // Sizes of lines and points
+ QString sizeStr ("line");
+ sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
+ sizeStr += gDigitsSep; sizeStr += "node";
+ sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
+ sizeStr += gDigitsSep; sizeStr += "shrink";
+ sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
+
+ param = vtkParam + "Sizes";
+ ip->setParameter(entry, param, sizeStr.toLatin1().data());
+
+ // Opacity
+ param = vtkParam + "Opacity";
+ ip->setParameter(entry, param,
+ QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
+
+ // Clipping
+ param = vtkParam + "ClippingPlane";
+ int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
+ if (!nPlanes)
+ ip->setParameter(entry, param, "Off");
+ for (int ipl = 0; ipl < nPlanes; ipl++) {
+ //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
+ SMESH::Orientation anOrientation;
+ double aDistance;
+ vtkFloatingPointType anAngle[2];
+ SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
+ std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
+ planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
+ planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
+ planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
+
+ ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
+ }
+ } // if (io->hasEntry())
+ } // SMESH_Actor && hasIO
+ } // isVisible
+ } // while.. actors traversal
+ } // if (vtkView)
+ } // for (views)
+ vtkViewers++;
+ } // if (SVTK view model)
+ } // for (viewManagers)
+}
+
+/*!
+ * \brief Restore visual parameters
+ *
+ * This method is called after the study document is opened.
+ * Restore visual parameters from AttributeParameter attribue(s)
+ */
+void SMESHGUI::restoreVisualParameters (int savePoint)
+{
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+ if (!appStudy || !appStudy->studyDS())
+ return;
+ _PTR(Study) studyDS = appStudy->studyDS();
+
+ // componentName is used for encoding of entries when storing them in IParameters
+ std::string componentName = myComponentSMESH->ComponentDataType();
+ //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
+ //if (!aSComponent) return;
+
+ // IParameters
+ _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
+ componentName.c_str(),
+ savePoint);
+ _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+
+ std::vector<std::string> entries = ip->getEntries();
+
+ for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
+ {
+ // entry is a normal entry - it should be "decoded" (setting base adress of component)
+ QString entry (ip->decodeEntry(*entIt).c_str());
+
+ // Check that the entry corresponds to a real object in the Study
+ // as the object may be deleted or modified after the visual state is saved.
+ _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
+ if (!so) continue; //Skip the not existent entry
+
+ std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
+ std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
+
+ std::vector<std::string>::iterator namesIt = paramNames.begin();
+ std::vector<std::string>::iterator valuesIt = paramValues.begin();
+
+ // actors are stored in a map after displaying of them for
+ // quicker access in the future: map < viewID to actor >
+ NCollection_DataMap<int, SMESH_Actor*> vtkActors;
+
+ for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
+ {
+ // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
+ // '_' is used as separator and should not be used in viewer type or parameter names.
+ QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
+ if (lst.size() != 3)
+ continue;
+
+ QString viewerTypStr = lst[0];
+ QString viewIndexStr = lst[1];
+ QString paramNameStr = lst[2];
+
+ bool ok;
+ int viewIndex = viewIndexStr.toUInt(&ok);
+ if (!ok) // bad conversion of view index to integer
+ continue;
+
+ // viewers
+ if (viewerTypStr == SVTK_Viewer::Type())
+ {
+ SMESH_Actor* aSmeshActor = 0;
+ if (vtkActors.IsBound(viewIndex))
+ aSmeshActor = vtkActors.Find(viewIndex);
+
+ if (paramNameStr == "Visibility")
+ {
+ if (!aSmeshActor && displayer())
+ {
+ QList<SUIT_ViewManager*> lst;
+ getApp()->viewManagers(viewerTypStr, lst);
+
+ // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
+ if (viewIndex >= 0 && viewIndex < lst.count()) {
+ SUIT_ViewManager* vman = lst.at(viewIndex);
+ SUIT_ViewModel* vmodel = vman->getViewModel();
+ // SVTK view model can be casted to SALOME_View
+ displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
+
+ // store displayed actor in a temporary map for quicker
+ // access later when restoring other parameters
+ SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
+ vtkRenderer* Renderer = vtkView->getRenderer();
+ vtkActorCollection* theActors = Renderer->GetActors();
+ theActors->InitTraversal();
+ bool isFound = false;
+ vtkActor *ac = theActors->GetNextActor();
+ for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
+ if (ac->IsA("SMESH_Actor")) {
+ SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
+ if (aGeomAc->hasIO()) {
+ Handle(SALOME_InteractiveObject) io =
+ Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
+ if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
+ isFound = true;
+ vtkActors.Bind(viewIndex, aGeomAc);
+ }
+ }
+ }
+ }
+ }
+ }
+ } // if (paramNameStr == "Visibility")
+ else
+ {
+ // the rest properties "work" with SMESH_Actor
+ if (aSmeshActor)
+ {
+ QString val ((*valuesIt).c_str());
+
+ // Representation
+ if (paramNameStr == "Representation") {
+ aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
+ }
+ // IsShrunk
+ else if (paramNameStr == "IsShrunk") {
+ if (val.toInt()) {
+ if (!aSmeshActor->IsShrunk())
+ aSmeshActor->SetShrink();
+ }
+ else {
+ if (aSmeshActor->IsShrunk())
+ aSmeshActor->UnShrink();
+ }
+ }
+ // Displayed entities
+ else if (paramNameStr == "Entities") {
+ QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
+ if (mode.count() == 6) {
+ if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
+ MESSAGE("Invalid order of data in Entities, must be: "
+ "e:0/1:f:0/1:v:0/1");
+ }
+ else {
+ unsigned int aMode = aSmeshActor->GetEntityMode();
+ unsigned int aNewMode =
+ (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
+ (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
+ (int(SMESH_Actor::eVolumes) * mode[5].toInt());
+ if (aNewMode != aMode)
+ aSmeshActor->SetEntityMode(aNewMode);
+ }
+ }
+ }
+ // Colors
+ else if (paramNameStr == "Colors") {
+ QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
+ if (colors.count() == 16) {
+ if (colors[0] != "surface" || colors[4] != "backsurface" ||
+ colors[8] != "edge" || colors[12] != "node") {
+ MESSAGE("Invalid order of data in Colors, must be: "
+ "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
+ }
+ else {
+ aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
+ aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
+ aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
+ aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
+ }
+ }
+ }
+ // Sizes of lines and points
+ else if (paramNameStr == "Sizes") {
+ QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
+ if (sizes.count() == 6) {
+ if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
+ MESSAGE("Invalid order of data in Sizes, must be: "
+ "line:int:node:int:shrink:float");
+ }
+ else {
+ aSmeshActor->SetLineWidth(sizes[1].toInt());
+ aSmeshActor->SetNodeSize(sizes[3].toInt());
+ aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
+ }
+ }
+ }
+ // Opacity
+ else if (paramNameStr == "Opacity") {
+ aSmeshActor->SetOpacity(val.toFloat());
+ }
+ // Clipping
+ else if (paramNameStr.startsWith("ClippingPlane")) {
+ cout << "$$$ ClippingPlane 1" << endl;
+ if (paramNameStr == "ClippingPlane1" || val == "Off")
+ aSmeshActor->RemoveAllClippingPlanes();
+ if (val != "Off") {
+ cout << "$$$ ClippingPlane 2" << endl;
+ QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
+ if (vals.count() == 4) { // format check: 4 values
+ cout << "$$$ ClippingPlane 3" << endl;
+ SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
+ double aDistance = vals[1].toFloat();
+ vtkFloatingPointType anAngle[2];
+ anAngle[0] = vals[2].toFloat();
+ anAngle[1] = vals[3].toFloat();
+
+ QList<SUIT_ViewManager*> lst;
+ getApp()->viewManagers(viewerTypStr, lst);
+ // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
+ if (viewIndex >= 0 && viewIndex < lst.count()) {
+ SUIT_ViewManager* vman = lst.at(viewIndex);
+ SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
+ SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
+ anOrientation, aDistance, anAngle);
+ }
+ }
+ }
+ }
+ } // if (aSmeshActor)
+ } // other parameters than Visibility
+ }
+ } // for names/parameters iterator
+ } // for entries iterator
+
+ // update all VTK views
+ QList<SUIT_ViewManager*> lst;
+ getApp()->viewManagers(lst);
+ for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
+ SUIT_ViewModel* vmodel = (*it)->getViewModel();
+ if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
+ SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
+ vtkView->getRenderer()->ResetCameraClippingRange();
+ vtkView->Repaint();
+ }
+ }
+}