- {
- SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
- if (Sel->IObjectCount() == 1) {
- Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
- if(anIObject->hasEntry())
- if(SMESH_Actor *anActor = ::FindActorByEntry(anIObject->getEntry())){
- anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
- }
- }
- 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;
- }
- 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;
- }
-
- }
-
- smeshGUI->myActiveStudy->updateObjBrowser(true);
- return true;
-}
-
-//=============================================================================
-/*! function : GetMeshesUsingAlgoOrHypothesis()
- * purpose : return a list of Study objects (mesh kind) that have 'AlgoOrHyp' affected.
- * : However is supposed here that father of father of an hypothesis is a Mesh Object.
- */
-//=============================================================================
-SALOMEDS::Study::ListOfSObject *
- SMESHGUI::GetMeshesUsingAlgoOrHypothesis(SMESH::
- SMESH_Hypothesis_ptr AlgoOrHyp)
-{
- SALOMEDS::Study::ListOfSObject_var listSOmesh =
- new SALOMEDS::Study::ListOfSObject;
- listSOmesh->length(0);
- unsigned int index = 0;
- if (!AlgoOrHyp->_is_nil()) {
- SALOMEDS::SObject_var SO_Hypothesis =
- smeshGUI->GetStudyAPI().FindObject(AlgoOrHyp);
- if (!SO_Hypothesis->_is_nil()) {
- SALOMEDS::Study::ListOfSObject_var listSO =
- smeshGUI->myStudy->FindDependances(SO_Hypothesis);
- MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<<listSO->length());
- for (unsigned int i = 0; i < listSO->length(); i++) {
- SALOMEDS::SObject_ptr SO = listSO[i];
- if (!SO->_is_nil()) {
- SALOMEDS::SObject_var aFather = SO->GetFather();
- if (!aFather->_is_nil()) {
- SALOMEDS::SObject_var SOfatherFather = aFather->GetFather();
- if (!SOfatherFather->_is_nil()) {
- MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list");
- index++;
- listSOmesh->length(index);
- listSOmesh[index - 1] = SOfatherFather;
- }
- }
- }
- }
- }
- }
- MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed");
- return listSOmesh._retn();
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Import_Mesh(QAD_Desktop * parent, int theCommandID){
- QString filter;
- string myExtension;
-
- if(theCommandID == 113){
- filter = tr("MED files (*.med)");
- }else if (theCommandID == 112){
- filter = tr("IDEAS files (*.unv)");
- }else if (theCommandID == 111){
- filter = tr("DAT files (*.dat)");
- }
- QString filename = QAD_FileDlg::getFileName(parent,
- "",
- filter,
- tr("Import mesh"),
- true);
- if(!filename.isEmpty()){
- QAD_WaitCursor wc;
- SMESH::mesh_array_var aMeshes;
- try {
- SMESH::DriverMED_ReadStatus res;
- aMeshes = smeshGUI->myComponentMesh->CreateMeshesFromMED(filename.latin1(),
- res);
- if ( res > SMESH::DRS_OK ) {
- wc.stop();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"),
- tr(QString("SMESH_DRS_%1").arg(res)),
- tr("SMESH_BUT_OK"));
- wc.start();
-
- }
- }
- catch (const SALOME::SALOME_Exception& S_ex)
- {
- wc.stop();
- QtCatchCorbaException(S_ex);
- wc.start();
- }
- for ( int i = 0, n = aMeshes->length(); i < n; i++ ) {
- SALOMEDS::SObject_var aMeshSO = smeshGUI->myStudyAPI.FindObject( aMeshes[i] );
- if ( !aMeshSO->_is_nil() ) {
- SALOMEDS::StudyBuilder_var aBuilder = smeshGUI->myStudy->NewBuilder();
- SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
- aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
- }
- }
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Export_Mesh(QAD_Desktop * parent, int theCommandID)
-{
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
- int nbSel = Sel->IObjectCount();
- if ( !nbSel )
- return;
- Standard_Boolean res;
- Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
- SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh(IObject, res);
- if ( res && ( nbSel == 1 || theCommandID == 122 ) ) {// MED export supports multiple meshes
- QString aFilter, aTitle = tr("Export mesh");
- switch ( theCommandID ) {
- case 122:
- aFilter = tr("MED files (*.med)");
- break;
- case 121:
- aFilter = tr("DAT files (*.dat)");
- break;
- case 123:
- aFilter = tr("IDEAS files (*.unv)");
- break;
- default:
- break;
- }
-
- QString filename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
-
- if ( !filename.isEmpty() ) {
- // Check whether the file already exists and delete it if yes
- QFile aFile( filename );
- if ( aFile.exists() )
- aFile.remove();
-
- QAD_WaitCursor wc;
- for ( SALOME_ListIteratorOfListIO it( Sel->StoredIObjects() ); it.More(); it.Next() ) {
- aMesh = smeshGUI->ConvertIOinMesh( it.Value(), res );
- if ( res ) {
- switch ( theCommandID ) {
- case 122:
- aMesh->ExportMED( filename.latin1(), true ); // currently, automatic groups are always created
- break;
- case 121:
- aMesh->ExportDAT( filename.latin1() );
- break;
- case 123:
- aMesh->ExportUNV( filename.latin1() );
- break;
- default:
- break;
- }
- }
- }
- }
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
- QAD_StudyFrame * studyFrame)
-{
- return false;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
- QAD_StudyFrame * studyFrame)
-{
- return true;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
- QAD_StudyFrame * studyFrame)
-{
- return true;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::SetSettings(QAD_Desktop * parent)
-{
- MESSAGE("SMESHGUI::SetSettings.");
- SMESHGUI::GetOrCreateSMESHGUI(parent);
-
- /* Display mode */
- QString DisplayMode = "Shading";
- if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
- DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
- else
- QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
-
- bool Shrink = false;
- if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
- Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
-
- 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);
-
- /* Automatic Update */
- QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
- if (AutoUpdate.compare("true") == 0) {
- parent->menuBar()->setItemChecked(1001, true);
- smeshGUI->myAutomaticUpdate = true;
- }
- else {
- parent->menuBar()->setItemChecked(1001, false);
- smeshGUI->myAutomaticUpdate = false;
- }
-
- /* Selection */
- ::UpdateSelectionProp();
-
- /* menus disable */
- parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
- parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
-
- return true;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
-{
- // NRI : Temporary added
- // if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) {
- // theObject = "NothingSelected";
- // theContext = "NothingSelected";
- // }
- // NRI
-
- SALOME_Selection *Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() );
- int nbSel = Sel->IObjectCount();
- switch ( nbSel ) {
- case 0:
- theObject = "NothingSelected";
- theContext = "NothingSelected";
- break;
- case 1:
- if ( smeshGUI->myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
- theObject = "Elements";
- else
- theObject = smeshGUI->CheckTypeObject( Sel->firstIObject() );
- theContext = "";
- break;
- default:
- theObject = smeshGUI->CheckHomogeneousSelection();
- theContext = "";
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
- const QString& theParent, const QString& theObject)
-{
- // get active study frame
- QAD_StudyFrame* studyFrame = smeshGUI->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( smeshGUI->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;
- }
- }
- else {
- // get selected interactive object
- Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
- SALOMEDS::SObject_var SO = smeshGUI->myStudy->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)
- QFont fnt = QApplication::font(); fnt.setBold( TRUE );
- 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 );
- }
- }
-
- // remove "Display only" command for component object
- if ( theObject.compare( "Component" ) == 0 ) {
- popup->removeItem( QAD_DisplayOnly_Popup_ID );
- }
- else 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 );
- }
- else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
- // get actor
- GEOM::GEOM_Shape_var aShape = GetSMESHGUI()->GetStudyAPI().GetShapeOnMeshOrSubMesh( SO );
- if ( aShape->_is_nil() ) {
- // imported mesh
- popup->removeItem( 701 ); // Compute
- popup->removeItem( 705 ); // Edit hypothesis
- popup->removeItem( 706 ); // ...
- }
- SMESH_Actor* ac = ::FindActorByEntry(IObject->getEntry());
- // if object has actor
- if ( ac && studyFrame->getTypeView() == VIEW_VTK ) {
- VTKViewer_RenderWindowInteractor* myRenderInter =
- ( ( VTKViewer_ViewFrame* ) studyFrame->getRightFrame()->getViewFrame() )->getRWInteractor();
- if ( myRenderInter->isVisible( IObject ) ) {
- popup->removeItem( QAD_Display_Popup_ID );
- popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes #
- popup->setItemChecked( 9011, ac->GetCellsLabeled() ); // Numbering / Display Elements #
- TVisualObjPtr aVisualObj = ac->GetObject();
- int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE);
- int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE);
- int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME);
- QMenuItem* mi = popup->findItem( 1131 );
- if ( mi && mi->popup() ) {
- int prType = ac->GetRepresentation();
- // Display Mode / Wireframe
- if(!aNbFaces && !aNbVolumes && !aNbEdges){
- mi->popup()->removeItem( 211 );
- }else{
- mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
- }
- // Display Mode / Shading
- if(!aNbFaces && !aNbVolumes){
- 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
- bool isShrunk = ac->IsShrunk();
- bool isShrunkable = ac->IsShrunkable();
- mi->popup()->setItemChecked( 213, isShrunk );
- mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
- }
- // Scalar Bar
- mi = popup->findItem( 2000 );
- if ( mi && mi->popup() ) {
- SMESH_Actor::eControl cMode = ac->GetControlMode();
- switch ( cMode ) {
- case SMESH_Actor::eLengthEdges:
- mi->popup()->setItemChecked( 6001, true ); 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;
- 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;
- 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;
- }
- TVisualObjPtr aVisualObj = ac->GetObject();
- SMESH::ElementType aType;
- if(!aNbEdges){
- mi->popup()->removeItem( 6001 );
- mi->popup()->removeItem( 6003 );
- mi->popup()->removeItem( 6004 );
- }
- if(!aNbFaces){
- mi->popup()->removeItem( 6011 );
- mi->popup()->removeItem( 6012 );
- mi->popup()->removeItem( 6013 );
- mi->popup()->removeItem( 6014 );
- mi->popup()->removeItem( 6015 );
- mi->popup()->removeItem( 6016 );
- }
- if(!aNbFaces && !aNbEdges)
- 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( 2000 ); // Scalar Bar
- }
- }
- 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() > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
- bDisplay = true;
- SMESH::SMESH_Group_var aGroupObj = SMESH::SMESH_Group::_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( 2000 ); // Scalar Bar
- }
- }
- else {
- // another SMESH object
- popup->removeItem( QAD_Display_Popup_ID );
- popup->removeItem( QAD_DisplayOnly_Popup_ID );
- popup->removeItem( QAD_Erase_Popup_ID );
- }
- }
- }
- 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 = smeshGUI->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
- QFont fnt = QApplication::font(); fnt.setBold( TRUE );
- popup->removeItem( QAD_TopLabel_Popup_ID );
- popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
- }
- }
- }
- }
- return false;
-}
-
-//=============================================================================
-/*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
- * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
- */
-//=============================================================================
-void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject) & theIO)
-{
- if(theIO->hasEntry()){
- QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
- QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
- ::UpdateView(aStudyFrame,eDisplay,theIO->getEntry());
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::setOrb()
-{
- try
- {
- ORB_INIT & init = *SINGLETON_ < ORB_INIT >::Instance();
- ASSERT(SINGLETON_ < ORB_INIT >::IsAlreadyExisting());
- _orb = init(0, 0);
- } catch(...)
- {
- INFOS("internal error : orb not found");
- _orb = 0;
- }
- ASSERT(!CORBA::is_nil(_orb));
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-SMESH_Actor *SMESHGUI::ReadScript(SMESH::SMESH_Mesh_ptr theMesh){}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Dump(SMESH_Actor * Mactor)
-{
- vtkUnstructuredGrid *ugrid = Mactor->GetUnstructuredGrid();
- vtkPoints *Pts = ugrid->GetPoints();
- int nbPts = Pts->GetNumberOfPoints();
- int nbCells = ugrid->GetNumberOfCells();
-
- FILE *In;
- int i, j;
- In = fopen("/tmp/dumpMesh", "w+");
- fprintf(In, "%d %d\n", nbPts, nbCells);
- for (int i = 0; i < nbPts; i++)
- {
- float *p = ugrid->GetPoint(i);
- fprintf(In, "%d %e %e %e\n", i, p[0], p[1], p[2]);
- }
-
- for (int i = 0; i < nbCells; i++)
- {
- fprintf(In, "%d %d", i, ugrid->GetCell(i)->GetCellType());
- vtkIdList *Id = ugrid->GetCell(i)->GetPointIds();
- for (j = 0; j < Id->GetNumberOfIds(); j++)
- {
- fprintf(In, " %d", Id->GetId(j));
- }
- fprintf(In, "\n");
- }
- fclose(In);
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::RemoveNodes(SMESH::SMESH_Mesh_ptr theMesh,
- const TColStd_MapOfInteger & MapIndex)
-{
- QAD_WaitCursor wc;
- try{
- SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh);
- CORBA::String_var anEntry = aSobj->GetID();
- if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){
- SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
- anArrayOfIdeces->length(MapIndex.Extent());
- TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
- for(int i = 0; ite.More(); ite.Next(), i++){
- anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key());
- }
- SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
- aMeshEditor->RemoveNodes(anArrayOfIdeces);
- if(myAutomaticUpdate){
- CORBA::Long anId = smeshGUI->myStudy->StudyId();
- if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){
- aVisualObj->Update(true);
- }
- }
- }
- }catch(SALOME::SALOME_Exception& exc) {
- INFOS("Follow exception was cought:\n\t"<<exc.details.text);
- }catch(const std::exception& exc){
- INFOS("Follow exception was cought:\n\t"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was cought !!!");
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::RemoveElements(SMESH::SMESH_Mesh_ptr theMesh,
- const TColStd_MapOfInteger & MapIndex)
-{
- QAD_WaitCursor wc;
- try{
- SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh);
- CORBA::String_var anEntry = aSobj->GetID();
- if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){
- SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
- anArrayOfIdeces->length(MapIndex.Extent());
- TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
- for(int i = 0; ite.More(); ite.Next(), i++){
- anArrayOfIdeces[i] = anActor->GetElemObjId(ite.Key());
- }
- SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
- aMeshEditor->RemoveElements(anArrayOfIdeces);
- if(myAutomaticUpdate){
- CORBA::Long anId = smeshGUI->myStudy->StudyId();
- if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){
- aVisualObj->Update(true);
- }
- }
- }
- }catch(SALOME::SALOME_Exception& exc) {
- INFOS("Follow exception was cought:\n\t"<<exc.details.text);
- }catch(const std::exception& exc){
- INFOS("Follow exception was cought:\n\t"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was cought !!!");
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::OrientationElements(SMESH::SMESH_Mesh_ptr aMesh,
- const TColStd_MapOfInteger & MapIndex)
-{
- MESSAGE("OrientationElements - not implemeted yet!");
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh,
- const TColStd_MapOfInteger & MapIndex)
-{
- MESSAGE("OrientationElements - not implemeted yet!");
-}
-
-//=====================================================================================
-// EXPORTED METHODS
-//=====================================================================================
-void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
-{
- if (!buffer || !bufferSize)
- return;
- buffer[0] = (int)VIEW_VTK;
-}
-
-void SMESHGUI::Deactivate()
-{
- if ( SMESHGUI::GetSMESHGUI() ) {
- SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();
- }
-}
-
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::SetPickable(SMESH_Actor* theActor){
- if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){
- int anIsAllPickable = (theActor == NULL);
- vtkRenderer *aRenderer = aViewFrame->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
- aCollection->InitTraversal();
- while(vtkActor *anAct = aCollection->GetNextActor()){
- if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
- if(anActor->GetVisibility()){
- anActor->SetPickable(anIsAllPickable);
- }
- }
- }
- if(theActor)
- theActor->SetPickable(!anIsAllPickable);
- RepaintCurrentView();
- }
-}
-
-
-void SMESHGUI::ViewNodes(){
- EraseSimulationActors();
- ::SetPointRepresentation(true);
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Control( int theCommandID ){
- SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->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 = ::FindActorByEntry(anIO->getEntry())){
- switch ( theCommandID ){
- case 6001:
- aTitle = tr( "LENGTH_EDGES" );
- aControl = SMESH_Actor::eLengthEdges;
- break;
- case 6003:
- aTitle = tr( "FREE_BORDERS" );
- aControl = SMESH_Actor::eFreeBorders;
- break;
- case 6004:
- aTitle = tr( "MULTI_BORDERS" );
- aControl = SMESH_Actor::eMultiConnection;
- break;
- case 6011:
- aTitle = tr( "AREA_ELEMENTS" );
- aControl = SMESH_Actor::eArea;
- break;
- case 6012:
- aTitle = tr( "TAPER_ELEMENTS" );
- aControl = SMESH_Actor::eTaper;
- break;
- case 6013:
- aTitle = tr( "ASPECTRATIO_ELEMENTS" );
- aControl = SMESH_Actor::eAspectRatio;
- break;
- case 6014:
- aTitle = tr( "MINIMUMANGLE_ELEMENTS" );
- aControl = SMESH_Actor::eMinimumAngle;
- break;
- case 6015:
- aTitle = tr( "WARP_ELEMENTS" );
- aControl = SMESH_Actor::eWarping;
- break;
- case 6016:
- aTitle = tr( "SKEW_ELEMENTS" );
- aControl = SMESH_Actor::eSkew;
- break;
- }
- anActor->SetControlMode(aControl);
- anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
- }
- }
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::SetSettingsScalarBar(vtkScalarBarActor * theScalarBar,
- QString Bold,
- QString Italic,
- QString Shadow,
- QString FontFamily,
- QString Orientation,
- float Width,
- float Height,
- int NbColors,
- int NbLabels)
-{
- if (Bold.isNull() || Bold.isEmpty() || (Bold.compare("true") == 0))
- theScalarBar->BoldOn();
- else
- theScalarBar->BoldOff();
-
- if (Italic.isNull() || Italic.isEmpty() || (Italic.compare("true") == 0))
- theScalarBar->ItalicOn();
- else
- theScalarBar->ItalicOff();
-
- if (Shadow.isNull() || Shadow.isEmpty() || (Shadow.compare("true") == 0))
- theScalarBar->ShadowOn();
- else
- theScalarBar->ShadowOff();
-
- if (FontFamily.compare("Arial") == 0)
- theScalarBar->SetFontFamilyToArial();
- else if (FontFamily.compare("Courier") == 0)
- theScalarBar->SetFontFamilyToCourier();
- else if (FontFamily.compare("Times") == 0)
- theScalarBar->SetFontFamilyToTimes();
- else
- theScalarBar->SetFontFamilyToArial();
-
- if (Orientation.isNull() || Orientation.isEmpty() ||
- (Orientation.compare("Vertical") == 0))
- theScalarBar->SetOrientationToVertical();
- else
- theScalarBar->SetOrientationToHorizontal();
-
- theScalarBar->SetWidth((Width == 0) ? 0.17 : Width);
- theScalarBar->SetHeight((Height == 0) ? 0.8 : Height);
-
- theScalarBar->SetNumberOfLabels((NbLabels == 0) ? 5 : NbLabels);
- theScalarBar->SetMaximumNumberOfColors((NbColors == 0) ? 64 : NbColors);
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::SetDisplaySettings()
-{
- 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;
-}
-
-//=======================================================================
-// function : Parameter()
-// purpose : return a parameter (double) from a dialog box
-//
-// aValue : is a double used as a default value displayed
-// aLabel : is the title for aValue1
-// aTitle : is the main title
-// bottom : maximum value to be entered
-// top : minimum value to be entered
-// decimals : number of decimals
-//=======================================================================
-double SMESHGUI::Parameter(Standard_Boolean & res,
- const double aValue,
- const char *aLabel,
- const char *aTitle,
- const double bottom, const double top, const int decimals)
-{
- SMESHGUI_aParameterDlg *Dialog =
- new SMESHGUI_aParameterDlg(QAD_Application::getDesktop(),
- aTitle,
- aLabel,
- bottom, top, decimals,
- TRUE);
- Dialog->setValue(aValue);
- double X = 0.0;
- res = (Dialog->exec() == QDialog::Accepted);
- if (res)
- X = Dialog->getDblValue();
- return X;
-}
-
-//=======================================================================
-// function : Parameter()
-// purpose : return a parameter (int) from a dialog box
-//
-// aValue : is a int used as a default value displayed
-// aLabel : is the title for aValue1
-// aTitle : is the main title
-// bottom : maximum value to be entered
-// top : minimum value to be entered
-//=======================================================================
-int SMESHGUI::Parameter(Standard_Boolean & res,
- const int aValue,
- const char *aLabel, const char *aTitle, const int bottom, const int top)
-{
- SMESHGUI_aParameterDlg *Dialog =
- new SMESHGUI_aParameterDlg(QAD_Application::getDesktop(),
- aTitle,
- aLabel,
- bottom, top,
- TRUE);
- Dialog->setValue(aValue);
- int X = 0;
- res = (Dialog->exec() == QDialog::Accepted);
- if (res)
- X = Dialog->getIntValue();
- return X;
-}